home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 23.4 KB | 801 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWEventD.cpp
- // Release Version: $ 1.0d11 $
- //
- // Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWOS.hpp"
-
- #ifndef FWEVENTD_H
- #include "FWEventD.h"
- #endif
-
- #ifndef FWEVENT_H
- #include "FWEvent.h"
- #endif
-
- #ifndef FWEVENTH_H
- #include "FWEventH.h"
- #endif
-
- #ifndef FWMNUBAR_H
- #include "FWMnuBar.h"
- #endif
-
- #ifndef FWPOINT_H
- #include "FWPoint.h"
- #endif
-
- #ifndef FWODMISS_H
- #include "FWODMiss.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODFacet_xh
- #include <Facet.xh>
- #endif
-
- // ----- Macintosh Includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__TOOLUTILS__)
- #include <ToolUtils.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #pragma segment FWEvents
-
- //========================================================================================
- // globals
- //========================================================================================
-
- unsigned short FW_CEventDispatcher::gAutoRepeatCount = 0;
-
- unsigned long FW_CEventDispatcher::gLastMouseUp = 0;
- short FW_CEventDispatcher::gClickCount = 1;
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- FW_DEFINE_CLASS_M0(FW_CEventDispatcher)
-
- //========================================================================================
- // class FW_CEventDispatcher
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::FW_CEventDispatcher
- //----------------------------------------------------------------------------------------
-
- FW_CEventDispatcher::FW_CEventDispatcher() :
- fLastMouseDownTarget(NULL),
- fLastMouseDownFrame(NULL),
- fEventHandler(NULL),
- fMenuBar(NULL)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::FW_CEventDispatcher
- //----------------------------------------------------------------------------------------
-
- FW_CEventDispatcher::FW_CEventDispatcher(FW_MEventHandler* theEventHandler, FW_CMenuBar* theMenuBar) :
- fLastMouseDownTarget(NULL),
- fLastMouseDownFrame(NULL),
- fEventHandler(theEventHandler),
- fMenuBar(theMenuBar)
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::~FW_CEventDispatcher
- //----------------------------------------------------------------------------------------
-
- FW_CEventDispatcher::~FW_CEventDispatcher()
- {
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::Dispatch
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::Dispatch(Environment* ev,
- ODEventData* event,
- ODFrame* odFrame,
- ODFacet* odFacet,
- ODEventInfo* eventInfo)
- {
- FW_Boolean handled = FALSE;
-
- #ifdef FW_BUILD_MAC
- switch (event->what)
- #endif
- #ifdef FW_BUILD_WIN
- switch (event->message)
- #endif
- {
-
- #ifdef FW_BUILD_MAC
- case nullEvent:
- #endif
- #ifdef FW_BUILD_WIN
- case WM_NULL:
- #endif
- handled = this->DispatchNullEvent(ev, event, odFrame);
- break;
-
- #ifdef FW_BUILD_MAC
- case mouseDown:
- #endif
- #ifdef FW_BUILD_WIN
- case WM_LBUTTONDOWN:
- case WM_MBUTTONDOWN:
- case WM_RBUTTONDOWN:
- #endif
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- case kODEvtBGMouseDown:
- #ifdef FW_BUILD_MAC
- handled = this->DispatchMouseDownEvent(ev, event, odFrame, odFacet, (event->what == kODEvtBGMouseDown));
- #endif
- #ifdef FW_BUILD_WIN
- handled = this->DispatchMouseDownEvent(ev, event, odFrame, odFacet, (event->message == kODEvtBGMouseDown));
- #endif
- break;
- #else
- handled = this->DispatchMouseDownEvent(ev, event, odFrame, odFacet, FALSE);
- break;
- #endif
-
- #ifdef FW_BUILD_MAC
- case mouseUp:
- #endif
- #ifdef FW_BUILD_WIN
- case WM_LBUTTONUP:
- case WM_MBUTTONUP:
- case WM_RBUTTONUP:
- #endif
- handled = this->DispatchMouseUpEvent(ev, event, odFrame, odFacet);
- break;
-
- #ifdef FW_BUILD_MAC
- case keyDown:
- case autoKey:
- #endif
- #ifdef FW_BUILD_WIN
- case WM_KEYDOWN:
- #endif
- handled = this->DispatchVirtualKeyDownEvent(ev, event, odFrame);
- break;
-
- #ifdef FW_BUILD_MAC
- case keyUp:
- #endif
- #ifdef FW_BUILD_WIN
- case WM_KEYUP:
- #endif
- handled = this->DispatchVirtualKeyUpEvent(ev, event, odFrame);
- break;
-
- #ifdef FW_BUILD_WIN
- case WM_CHAR:
- handled = this->DispatchCharKeyEvent(ev, event, odFrame);
- break;
- #endif
-
- #ifdef FW_BUILD_MAC
- case activateEvt:
- #endif
- #ifdef FW_BUILD_WIN
- case WM_ACTIVATE:
- #endif
- handled = this->DispatchActivateEvent(ev, event, odFrame, odFacet);
- break;
-
- case kODEvtMenu:
- handled = this->DispatchMenuEvent(ev, event, odFrame);
- break;
-
- #ifdef FW_BUILD_MAC
- case kODEvtWindow:
- handled = this->DispatchWindowEvent(ev, event, odFacet);
- break;
- case osEvt:
- handled = this->DispatchOSEvent(ev, event, odFacet);
- break;
- #endif
-
- case kODEvtMouseDownEmbedded:
- #if FW_OPENDOC_VERSION >= FW_OPENDOC_DR3
- case kODEvtBGMouseDownEmbedded:
- #ifdef FW_BUILD_MAC
- handled = this->DispatchEmbeddedMouseDownEvent(ev, event, odFrame, odFacet, eventInfo, (event->what == kODEvtBGMouseDownEmbedded));
- #endif
- #ifdef FW_BUILD_WIN
- handled = this->DispatchEmbeddedMouseDownEvent(ev, event, odFrame, odFacet, eventInfo, (event->message == kODEvtBGMouseDownEmbedded));
- #endif
- break;
- #else
- handled = this->DispatchEmbeddedMouseDownEvent(ev, event, odFrame, odFacet, eventInfo, FALSE);
- break;
- #endif
-
- case kODEvtMouseUpEmbedded:
- handled = this->DispatchEmbeddedMouseUpEvent(ev, event, odFrame, odFacet, eventInfo);
- break;
-
- case kODEvtMouseDownBorder:
- handled = this->DispatchBorderMouseDownEvent(ev, event, odFrame, odFacet, eventInfo);
- break;
-
- case kODEvtMouseEnter:
- handled = this->DispatchMouseEnterEvent(ev, odFacet, eventInfo);
- break;
-
- case kODEvtMouseWithin:
- handled = this->DispatchMouseWithinEvent(ev, odFacet, eventInfo);
- break;
-
- case kODEvtMouseLeave:
- handled = this->DispatchMouseLeaveEvent(ev, odFacet, eventInfo);
- break;
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchNullEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchNullEvent(Environment* ev, ODEventData* event, ODFrame* odFrame)
- {
- FW_CNullEvent theNullEvent(ev, event);
- FW_MEventHandler* target = fEventHandler;
-
- if (odFrame)
- {
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
- target = fwFrame->GetTarget(ev);
- FW_ASSERT(target != NULL);
- }
-
- return target->HandleIdle(ev, theNullEvent);
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchMouseDownEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchMouseDownEvent(Environment* ev, ODEventData* event, ODFrame* odFrame, ODFacet* odFacet, FW_Boolean inBackground)
- {
- short numOfClicks = OnMouseDown(ev, event);
-
- FW_CMouseEvent theMouseEvent(ev, event, odFacet, FW_CMouseEvent::kMouseButtonDown, numOfClicks);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
-
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- FW_MEventHandler* target = fwFrame->PrivGetEventHandlerContaining(ev, odFacet, where);
- FW_ASSERT(target);
-
- // FW_ASSERT(fLastMouseDownTarget == NULL);
- // FW_ASSERT(fLastMouseDownFrame == NULL);
- fLastMouseDownTarget = target;
- fLastMouseDownFrame = fwFrame;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = inBackground ? target->DispatchBGMouseDown(ev, theMouseEvent)
- : target->DispatchMouseDown(ev, theMouseEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchMouseUpEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchMouseUpEvent(Environment* ev, ODEventData* event, ODFrame* odFrame, ODFacet* odFacet)
- {
- OnMouseUp(ev, event);
-
- FW_CMouseEvent theMouseEvent(ev, event, odFacet, FW_CMouseEvent::kMouseButtonUp);
-
- FW_MEventHandler* target = NULL;
-
- // FW_ASSERT(fLastMouseDownTarget != NULL);
- // FW_ASSERT(fLastMouseDownFrame != NULL);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
-
- if (fLastMouseDownFrame == fwFrame)
- target = fLastMouseDownTarget;
- else
- {
- FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- target = fwFrame->PrivGetEventHandlerContaining(ev, odFacet, where);
- }
-
- fLastMouseDownTarget = NULL;
- fLastMouseDownFrame = NULL;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMouseUp(ev, theMouseEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchEmbeddedMouseDownEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchEmbeddedMouseDownEvent(Environment* ev,
- ODEventData* event,
- ODFrame* odFrame,
- ODFacet* odFacet,
- ODEventInfo* eventInfo,
- FW_Boolean inBackground)
- {
- short numOfClicks = OnMouseDown(ev, event);
-
- FW_CEmbeddedMouseEvent theEmbeddedMouseEvent(ev,
- event,
- odFacet,
- eventInfo->embeddedFrame,
- eventInfo->embeddedFacet,
- FW_CMouseEvent::kMouseButtonDown,
- numOfClicks);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
-
- FW_CPoint where = theEmbeddedMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- FW_MEventHandler* target = fwFrame->PrivGetEventHandlerContaining(ev, odFacet, where);
- FW_ASSERT(target);
-
- // FW_ASSERT(fLastMouseDownTarget == NULL);
- // FW_ASSERT(fLastMouseDownFrame == NULL);
- fLastMouseDownTarget = target;
- fLastMouseDownFrame = fwFrame;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = inBackground ? target->DispatchBGMouseDownInEmbeddedFrame(ev, theEmbeddedMouseEvent)
- : target->DispatchMouseDownInEmbeddedFrame(ev, theEmbeddedMouseEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchEmbeddedMouseUpEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchEmbeddedMouseUpEvent(Environment* ev, ODEventData* event, ODFrame* odFrame, ODFacet* odFacet, ODEventInfo* eventInfo)
- {
- OnMouseUp(ev, event);
-
- FW_CEmbeddedMouseEvent theEmbeddedMouseEvent(ev,
- event,
- odFacet,
- eventInfo->embeddedFrame,
- eventInfo->embeddedFacet,
- FW_CMouseEvent::kMouseButtonUp);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
-
- FW_MEventHandler* target = NULL;
-
- // FW_ASSERT(fLastMouseDownTarget != NULL);
- // FW_ASSERT(fLastMouseDownFrame != NULL);
-
- if (fLastMouseDownFrame == fwFrame)
- target = fLastMouseDownTarget;
- else
- {
- FW_CPoint where = theEmbeddedMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- target = fwFrame->PrivGetEventHandlerContaining(ev, odFacet, where);
- }
-
- fLastMouseDownTarget = NULL;
- fLastMouseDownFrame = NULL;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMouseUpInEmbeddedFrame(ev, theEmbeddedMouseEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchBorderMouseDownEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchBorderMouseDownEvent(Environment* ev, ODEventData* event, ODFrame* odFrame, ODFacet* odFacet, ODEventInfo* eventInfo)
- {
- short numOfClicks = OnMouseDown(ev, event);
-
- FW_CBorderMouseEvent theBorderMouseEvent(ev,
- event,
- odFacet,
- eventInfo->embeddedFrame,
- eventInfo->embeddedFacet,
- FW_CMouseEvent::kMouseButtonDown,
- numOfClicks);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
-
- FW_CPoint where = theBorderMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
- FW_MEventHandler* target = fwFrame->PrivGetEventHandlerContaining(ev, odFacet, where);
- FW_ASSERT(target);
-
- // FW_ASSERT(fLastMouseDownTarget == NULL);
- // FW_ASSERT(fLastMouseDownFrame == NULL);
- fLastMouseDownTarget = target;
- fLastMouseDownFrame = fwFrame;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMouseDownInEmbeddedFrameBorder(ev, theBorderMouseEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchVirtualKeyDownEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchVirtualKeyDownEvent(Environment* ev, ODEventData* event, ODFrame* odFrame)
- {
- FW_Boolean handled = FALSE;
-
- #ifdef FW_BUILD_MAC
- if (event->what == autoKey)
- gAutoRepeatCount++;
- else
- gAutoRepeatCount = 0;
-
- FW_CVirtualKeyEvent theVirtualKeyEvent(ev, event, FW_CVirtualKeyEvent::kKeyDown, gAutoRepeatCount);
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_CVirtualKeyEvent theVirtualKeyEvent(ev, event, FW_CVirtualKeyEvent::kKeyDown, LOWORD(event->lParam));
- #endif
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
- FW_MEventHandler* target = fwFrame->GetTarget(ev);
- FW_ASSERT(target != NULL);
-
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchVirtualKey(ev, theVirtualKeyEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- #ifdef FW_BUILD_MAC
- // If the keycode isn't used try the char
- if (!handled)
- handled = this->DispatchCharKeyEvent(ev, event, odFrame);
- #endif
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchVirtualKeyUpEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchVirtualKeyUpEvent(Environment* ev, ODEventData* event, ODFrame* odFrame)
- {
- FW_CVirtualKeyEvent theVirtualKeyEvent(ev, event, FW_CVirtualKeyEvent::kKeyUp);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
- FW_MEventHandler* target = fwFrame->GetTarget(ev);
- FW_ASSERT(target != NULL);
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchVirtualKey(ev, theVirtualKeyEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchCharKeyEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchCharKeyEvent(Environment* ev, ODEventData* event, ODFrame* odFrame)
- {
- #ifdef FW_BUILD_MAC
- FW_CCharKeyEvent theCharKeyEvent(ev, event, gAutoRepeatCount);
- #endif
- #ifdef FW_BUILD_WIN
- FW_CCharKeyEvent theCharKeyEvent(ev, event, LOWORD(event->lParam));
- #endif
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
- FW_MEventHandler* target = fwFrame->GetTarget(ev);
- FW_ASSERT(target != NULL);
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchCharKey(ev, theCharKeyEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchActivateEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchActivateEvent(Environment* ev, ODEventData* event, ODFrame* odFrame, ODFacet* odFacet)
- {
- FW_UNUSED(odFrame);
-
- #ifdef FW_BUILD_MAC
- FW_CActivateEvent theActivateEvent(ev, event, odFacet, (event->modifiers & activeFlag ) != 0);
- #endif
- #ifdef FW_BUILD_WIN
- FW_CActivateEvent theActivateEvent(ev, event, odFacet, (event->wParam != WA_INACTIVE));
- #endif
-
- FW_MEventHandler* target = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(target != NULL);
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchActivateEvent(ev, theActivateEvent);
-
- target = target->GetNextEventHandler(ev);
- }
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchMenuEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchMenuEvent(Environment* ev, ODEventData* event, ODFrame* odFrame)
- {
- ODCommandID theCommand;
-
- #ifdef FW_BUILD_MAC
- ODMenuID menu = HiWord(event->message);
- ODMenuItemID item = LoWord(event->message);
- theCommand = fMenuBar->PrivMacGetCommand(ev, menu, item);
- #endif
- #ifdef FW_BUILD_WIN
- theCommand = event->wParam;
- #endif
-
- FW_CMenuEvent theMenuEvent(ev, event, theCommand);
-
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFrame);
- FW_ASSERT(fwFrame != NULL);
- FW_MEventHandler* target = fwFrame->GetTarget(ev);
- FW_ASSERT(target != NULL);
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMenuEvent(ev, theMenuEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- #ifdef FW_BUILD_MAC
- ::HiliteMenu(0);
- #endif
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchMouseEnterEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchMouseEnterEvent(Environment* ev, ODFacet* odFacet, ODEventInfo* eventInfo)
- {
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFacet->GetFrame(ev));
- FW_ASSERT(fwFrame != NULL);
-
- FW_CPoint point(eventInfo->where);
- FW_MEventHandler* target = fwFrame;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMouseEnter(ev, odFacet, point);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchMouseWithinEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchMouseWithinEvent(Environment* ev, ODFacet* odFacet, ODEventInfo* eventInfo)
- {
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFacet->GetFrame(ev));
- FW_ASSERT(fwFrame != NULL);
-
- FW_CPoint point(eventInfo->where);
-
- FW_MEventHandler* target = fwFrame;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMouseWithin(ev, odFacet, point);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchMouseLeaveEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchMouseLeaveEvent(Environment* ev, ODFacet* odFacet, ODEventInfo* eventInfo)
- {
- FW_MEventHandler* fwFrame = FW_MEventHandler::ODFrameToEventHandler(ev, odFacet->GetFrame(ev));
- FW_ASSERT(fwFrame != NULL);
-
- FW_CPoint point(eventInfo->where);
-
- FW_MEventHandler* target = fwFrame;
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchMouseLeave(ev, odFacet);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchWindowEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchWindowEvent(Environment* ev, ODEventData* event, ODFacet* odFacet)
- {
- FW_CMacWindowEvent windowEvent(ev, event);
-
- FW_MEventHandler* target = FW_MEventHandler::ODFrameToEventHandler(ev, odFacet->GetFrame(ev));
- FW_ASSERT(target != NULL);
-
- FW_Boolean handled = FALSE;
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchWindowEvent(ev, windowEvent);
-
- target = target->GetNextEventHandler(ev);
- }
-
- return handled;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::DispatchOSEvent
- //----------------------------------------------------------------------------------------
-
- FW_Boolean FW_CEventDispatcher::DispatchOSEvent(Environment* ev, ODEventData* event, ODFacet* odFacet)
- {
- FW_Boolean handled = FALSE;
-
- if (((unsigned char) ( event->message >> 24 ) & 0x00FF) == 0x01)
- {
- const short kResumeMask = 0x01; // High byte suspend/resume event
-
- FW_Boolean goingToBackground = (event->message & kResumeMask) == 0;
- FW_CSuspendResumeEvent suspendResumeEvent(ev, event, odFacet, goingToBackground);
-
- FW_MEventHandler* target = FW_MEventHandler::ODFrameToEventHandler(ev, odFacet->GetFrame(ev));
- FW_ASSERT(target != NULL);
-
- while (target != NULL && handled == FALSE)
- {
- handled = target->DispatchSuspendResumeEvent(ev, suspendResumeEvent);
-
- target = target->GetNextEventHandler(ev);
- }
- }
-
- return handled;
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::OnMouseUp
- //----------------------------------------------------------------------------------------
-
- void FW_CEventDispatcher::OnMouseUp(Environment* ev, ODEventData* event)
- {
- #ifdef FW_BUILD_MAC
- gLastMouseUp = event->when;
- #endif
-
- #ifdef FW_BUILD_WIN
- gLastMouseUp = 0;
- #endif
- }
-
- //----------------------------------------------------------------------------------------
- // FW_CEventDispatcher::OnMouseDown
- //----------------------------------------------------------------------------------------
-
- short FW_CEventDispatcher::OnMouseDown(Environment* ev, ODEventData* event)
- {
- #ifdef FW_BUILD_MAC
- if (event->when - gLastMouseUp < ::GetDblTime())
- gClickCount++;
- else
- gClickCount = 1;
- #endif
-
- #ifdef FW_BUILD_WIN
- gClickCount = 1;
- #endif
-
- return gClickCount;
- }